//
//  AppDelegate.m
//  genericframework
//
//  Created by 谷丰 on 2025/3/25.
//

#import "AppDelegate.h"
#import "AppConfigVC.h"
@interface AppDelegate ()

@end

@implementation AppDelegate



-(UIWindow *)window{
    if(!_window){
        _window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
        _window.backgroundColor = [UIColor whiteColor];
        
    }
    return _window;
    
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
   
    
    // 注册通知
    [[NSNotificationCenter defaultCenter] addObserver:self
                                           selector:@selector(languageDidChange)
                                               name:@"LanguageDidChange"
                                             object:nil];
    
    // 注册通知登录成功或者获取配置成功后
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(RootChange)
                                               name:@"ROOTCHANGE"
                                             object:nil];
   
    AppConfigVC * first=   [[AppConfigVC alloc]init];
    self.window.rootViewController = first;
    [self.window makeKeyAndVisible];
  

   
    return YES;
}
-(void)RootChange{
    
    
    if ([BaseWay getToken]) {
        [self Root];
    }else{
        LoginVC * first=   [[LoginVC alloc]init];
        BaseNavigationController * Nav = [[BaseNavigationController alloc]initWithRootViewController:first];
        self.window.rootViewController = Nav;
        [self.window makeKeyAndVisible];
        
    }
    
    
   
    
    
}
- (void)requestData{
   
}

// 处理语言变化
- (void)languageDidChange {
       // 更新界面显示
       [self Root];
}
-(void)Root{
        self.Tabbar =[[BaseTabBar alloc]init];
        self.window.rootViewController = self.Tabbar;
        [self.window makeKeyAndVisible];
}

@end
